#递归的两个阶段:
# 1.回溯:一层一层调用下去
# 2.递推：满足某种条件，结束递归调用，然后一层一层返回


# age(5)=age(4)+10
# age(4)=age(3)+10
# age(3)=age(2)+10
# age(2)=age(1)+10
# age(1)=18
def age(n):
    if n==1:
        return 18
    else:
        return age(n-1)+10
print(age(5))
def func(day,x2=1):
    if day==1:
        return func(day)
    else:
        day-=1
        x1=(x2+1)*2
    return func(day,x1)+x1
res=func(10)
print(res)
#递归的应用
l=[1,2,[3,[4,[5,[6,[7,[8,[9,10,11]]]]]]]]
l1=[]
def func(l):
    for x in l:
        if type(x) is list:
            func(x)
        else:
            l1.append(x)
    return l1
print(func(l))